翻訳と辞書
Words near each other
・ Most Reverend
・ Most royal candidate theory
・ Most Sacred Heart of Jesus Catholic Church (Hawi, Hawaii)
・ Most Secret
・ Most Serene Republic
・ Most Shocking
・ Most significant bit
・ Most significant change technique
・ Most SNP
・ Most Terrifying Places in America
・ Most Valuable Canadian
・ Most valuable customers
・ Most Valuable Player
・ Most Valuable Player Award (PIHA)
・ Most Valuable Players (film)
Most vexing parse
・ Most Wanted
・ Most Wanted (1997 film)
・ Most Wanted (2011 film)
・ Most Wanted (Hilary Duff album)
・ Most Wanted (Kane & Abel album)
・ Most Wanted (TV series)
・ Most wanted list
・ Most Wanted Tour
・ Most Welcome
・ Most Welcome 2
・ Most, Kardzhali Province
・ Most, Mokronog–Trebelno
・ Most-Favoured-Customer Clause
・ Most-perfect magic square


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Most vexing parse : ウィキペディア英語版
Most vexing parse
The most vexing parse is a specific form of syntactic ambiguity resolution in the C++ programming language. The term was used by Scott Meyers in ''Effective STL'' (2001). It is formally defined in section 8.2 of the C++ language standard.〔ISO/IEC (2003). ''ISO/IEC 14882:2003(E): Programming Languages - C++ §8.2 Ambiguity resolution ()''〕
== Example with classes ==
An example is:

class Timer ;
class TimeKeeper ;
int main()

The line

TimeKeeper time_keeper(Timer());

is ambiguous, since it could be interpreted either as
# a variable definition for variable of class , initialized with an anonymous instance of class or
# a function declaration for a function which returns an object of type and has a single (unnamed) parameter which is a function returning type (and taking no input). (See Function object#In C and C++)
Most programmers expect the first, but the C++ standard requires it to be interpreted as the second.
For example, g++ gives the following error message:

$ g++ -c time_keeper.cc
time_keeper.cc: In function ‘int main()’:
time_keeper.cc:15: error: request for member ‘get_time’ in ‘time_keeper’, which is
of non-class type ‘TimeKeeper(Timer (
*)())’

Clang++ provides a warning:
$ clang++ time_keeper.cc
timekeeper.cc:14:25: parentheses were disambiguated as a function declaration
()
TimeKeeper time_keeper(Timer());

timekeeper.cc:14:26: note: add a pair of parentheses to declare a variable
TimeKeeper time_keeper(Timer());


timekeeper.cc:15:21: member reference base type 'TimeKeeper (Timer (
*)())' is not a
structure or union
return time_keeper.get_time();

One way to force the compiler to consider this as a variable definition is to add an extra pair of parentheses:

TimeKeeper time_keeper( (Timer()) );


抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Most vexing parse」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.